package com.zmn.oms.services.impl.track;

import com.alibaba.fastjson.JSON;
import com.zmn.common.utils.string.StringUtil;
import com.zmn.manager.mq.constant.MqTopicConsts;
import com.zmn.manager.mq.interfaces.ZmnMQSender;
import com.zmn.oms.manager.utils.OmsMqTagConsts;
import com.zmn.oms.model.entity.warn.OrderWarnReplyEvent;
import com.zmn.oms.services.interfaces.warn.OrderWarnReplyService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * 类描述：
 *
 * @author LiangHailong
 * @date 2019/07/30 11:27
 */
@Slf4j
@Service
public class OrderWarnReplyServiceImpl implements OrderWarnReplyService {
    @Resource
    private ZmnMQSender zmnMQSender;

    @Override
    public void orderWarnReplySync(OrderWarnReplyEvent orderWarnReplyEvent) {
            String key = "sync_api_" + StringUtil.getRandomStringAndNumber3(20);
            orderWarnReplyEvent.setMqMsgKey(key);
            String json = JSON.toJSONString(orderWarnReplyEvent);
            log.info("#order#sync#api#orderWarn info:{} key:{}", json, key);
            zmnMQSender.send(MqTopicConsts.ZMN_TOPIC_OMS, OmsMqTagConsts.ZMN_TOPIC_OMS_ORDER_WARN_REPLY_SYNC_API, key, json);
    }
}
